#!/usr/bin/env python

from __future__ import unicode_literals, print_function

from six import text_type

from veles.scli import client
from veles.schema.nodeid import NodeID
from veles.util import helpers

parser = helpers.get_client_argparse()
parser.add_argument('file', help='path to file to upload', type=text_type)
args = parser.parse_args()

client = client.create_client(args.server_url)

with open(args.file, 'rb') as f:
    data = f.read()

id = client.create(NodeID.root_id,
    tags={'blob', 'blob.file', 'blob.stored',},
    attr={
        'name': args.file,
        'path': args.file,
        'width': 8,
        'base': 0,
        'size': len(data),
    },
    bindata={
        'data': data,
    }
)
print('CREATED', id)
